<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}

.buyinfor-table tr td button {
	margin-top: 12px;
}
</style>
</head>
<body class="gray-bg">

	<!-- 隐藏域 -->
	<input type="hidden" value="${busiId}" id="busiId" name="busiId" />
	<input type="hidden" id="dzMortgage_id" name="dzMortgage_id" />

	<input type="hidden" id="replaceId" name="replaceId" />
	<input type="hidden" id="status_mortgage_info" name="status_mortgage_info" />
	<!-- 隐藏域 -->

	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷中业务>抵押确认</span>
			<a href="javascript:void(0)"></a>
		</div>
		<div class="ibox-content ibox-con">
			<form class="form-horizontal" id="commentForm">
				<%@include file="/jsp/common_yw_include.jsp"%>
				<%@include file="/jsp/common_car_include.jsp"%>
				<div class="business-manwife">车牌信息</div>
				<div class="business-padding">
					<table cellpadding="0" cellspacing="0" border="0"
						class="infor-table list-table-detail">
						<tr>
							<td align="right"><label class="control-label">上牌地：</label></td>
							<td>
								<div class="control-div np" id="che_region" name="">${businessCar[0].get('registration_area')}</div>
							</td>
							<td align="right"><label class="control-label">车管所：</label></td>
							<td>
								<div class="control-div np" id="che_dvm" name="">${businessCar[0].get('dvm')}</div>
							</td>
						</tr>
			
						<tr>
			
							<td align="right"><label class="control-label">车牌号：</label></td>
							<td>
								<div class="control-div np" id="che_licensePlate" name="">${businessCar[0].get('license_plate')}</div>
							</td>
			
							<td align="right"><label class="control-label">机动车登记证号：</label>
							</td>
							<td>
								<div class="control-div np" id="che_registrationNumber" name="">${businessCar[0].get('registration_number')}</div>
							</td>
						</tr>
			
						<tr>
							<td align="right"><label class="control-label">新车上牌时间：</label>
							</td>
							<td>
								<div class="control-div np" id="che_dateRegistrationFirst" name="">${businessCar[0].get('date_registration_first')}</div>
							</td>
							<td align="right"><label class="control-label">本次上牌登记时间：</label>
							</td>
							<td>
								<div class="control-div np" id="che_dateRegistrationNow" name="">${businessCar[0].get('date_registration_now')}</div>
							</td>
						</tr>
						<tr>
							<td align="right"><label class="control-label">备注：</label></td>
							<td colspan="3">
								<div class="control-div np" id="che_remarks" name="">${businessCar[0].get('remarks')}</div>
							</td>
						</tr>
						<tr>
							<td align="right"><label class="control-label">银行放款时间：</label></td>
							<td colspan="3">
								<div class="control-div np" id="che_remarks" name="">${timeLending}</div>
							</td>
						</tr>
					</table>
				</div>
				<div class="business-manwife">抵押确认</div>
				<div class="padding-nono">
					<table cellpadding="0" cellspacing="0" border="0"
						class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">实际抵押时间：</label>
							</td>
							<td><input id="date_mortgage" name="date_mortgage" placeholder="请输入时间(必填)" required="required" class="laydate-icon form-control" onclick="laydate()" /></td>
							<td align="right"><label class="control-label np">经办时间：</label>
							</td>
							<td><input id="time_mortgage" name="time_mortgage" placeholder="经办时间(必填)" required="required" class="laydate-icon form-control" onclick="laydate()" /></td>
						</tr>
						<tr>
							<!--  
							<td align="right">
								<label class="control-label np">抵押成功状态：</label>
							</td>
							<td>
								<select id="status_mortgage" name="status_mortgage" class="select-control" required="required"></select>
							</td>
							-->
							<td align="right"><label class="control-label np">抵押经办人：</label>
							</td>
							<td><input id="operator_mortgage" name="operator_mortgage" required="required" placeholder="抵押经办人(必填)" class="form-control" type="text" /></td>
						</tr>
						<tr>
							<td align="right" valign="top"><label class="control-label np">备注：</label></td>
							<td colspan="5"><textarea id="remarks" name="remarks" maxlength="200" style="word-break: break-all; word-wrap: break-word; height: 70px;" class="form-control"></textarea></td>
						</tr>
						<tr>
							<td align="right" valign="top"><label class="control-label np">&nbsp;</label></td>
							<td colspan="5">
								<button type="button" id="button1" class="btn dpbtn_green" onclick="btnSuccess(03);">保存</button>
								<button type="button" id="button2" class="btn dpbtn_green" onclick="btnSuccess(01);">抵押成功</button>
								<button type="button" id="button3" class="btn dpbtn_green" onclick="btnSuccess(02);">抵押失败</button>
							</td>
						</tr>
					</table>
					
				</div>
				<!-- 当前经办人 -->
				<%@include file="/jsp/comm_current_person_include.jsp"%>
			</form>
		</div>
		<!-- public quote -->
		<%@include file="/jsp/comm_js_include.jsp"%>
		<!-- summernote -->
		<%@include
			file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>

		<!-- layerDate plugin javascript -->
		<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

		<%@include
			file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>

		<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
		<script type="text/javascript">
	    
	    var winWidth = $(window).width();
		var winHeight = $(window).height();
		
	    jQuery(function($) {
	    	initData();
	    });
	    
	    var initData = function()
	    {
	    	var busiId = $('#busiId').val();
	    	
	    	$.dpAjax({
	    		url:'${basePath}/DaiZhongYwController/daiZhongYwDiYaQueRrnList',
	    		data:{
	    			"busiId":busiId
	    		},
	    		success: function(datas){
					  var d = datas.dzMortgage;
					  if(null != d && d != "")
					  {
						  $('#dzMortgage_id').val(d.replaceId);
						  
						  $('#operator_mortgage').val(d.operatorMortgage);
						  $('#time_mortgage').val(d.timeMortgage ? formateToDate(d.timeMortgage) : '');
						  $('#date_mortgage').val(d.dateMortgage ? formateToDate(d.dateMortgage) : '');
						  
						  $('#replaceId').val(d.replaceId);
						  $('#status_mortgage_info').val(d.statusMortgageInfo);
						  $('#remarks').val(d.remarks);
						  
						  if(d.statusMortgage == 1 || d.statusMortgage == 2)
						  {
							  $('#date_mortgage').attr("disabled","disabled");
							  $('#time_mortgage').attr("disabled","disabled");
							  $('#operator_mortgage').attr("disabled","disabled");
							  
							  $('#button2').attr("disabled","disabled");
							  $('#button3').attr("disabled","disabled");
						  }
						  
						  var status_mortgage_info = $('#status_mortgage_info').val();
						  if(status_mortgage_info == "20")
						  {
							  $('#button1').attr("disabled","disabled");
							  $('#remarks').attr("disabled","disabled");
						  }
					  }
    		     }
	    	});
	    }
	    
	    //抵押保存
	    var btnSuccess = function(status_mortgage)
	    {
	    	var status = $("#commentForm").valid();
			if(!status) 
			{
				layer.msg('有验证未通过，请仔细检查！', {icon: 5});
				return;
			}
			
	    	var operator_mortgage = $('#operator_mortgage').val();
	    	var time_mortgage = $('#time_mortgage').val();
	    	var date_mortgage = $('#date_mortgage').val();
	    	var remarks = $('#remarks').val();
	    	var busiId = $('#busiId').val();
			
	    	
	    	//询问框
	    	layer.confirm('确定执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	    	  btn: ['确认','取消'] //按钮
	    	}, function(){
	    		layer.closeAll();
	    		$.dpAjax({
		    		url:'${basePath}/DaiZhongYwController/daiZhongYwDiYaQueRrnSave',
		    		data:{
		    			"busiId":busiId,
		    			"operatorMortgage":operator_mortgage,
		    			"timeMortgage":time_mortgage,
		    			"statusMortgage":status_mortgage,
		    			"dateMortgage":date_mortgage,
		    			"remarks":remarks
		    		},
		    		success: function(datas)
		    		{
		    			layer.msg("执行成功！", {icon: 6});
		    			initData();
	    		    }
		    	});
	    		
	    	}, function(){
	    		layer.msg('已取消本次操作！', {icon: 6});
	    	});
	    }
	    
	    $(function(){	
	        $("#commentForm").validate({
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
	        
		})
    </script>
</body>
</html>
